﻿using System;
using System.Text;

using Notepad_X;
using Notepad_X.Plugin;

namespace SnippetsSidebarPlugin
{
    public class plugin : IPlugin
    {
        Snippets PluginContainer;

        SideBarPlugin.plugin Sidebar = null;

        public string Name
        { get { return "Snippets Sidebar Plugin"; } }
        public string Author
        { get { return "NohponeX"; } }
        public string Description
        { get { return "Notepad X Sidebar Plugin\n\r Snippets Plugin \n\r Requires Notepad X 2.1.3 or newer"; } }
        public string Version
        { get { return "1.1.2"; } }
        public bool HasSettings
        { get { return false; } }

        public void Initialize(){
            try
            {
                Sidebar = SideBarPlugin.Functions.GetSidebarPlugin();
                if (Sidebar != null)
                {
                    if (!Sidebar.Controls.ContainsKey("Snippets Sidebar Plugin"))
                    {
                        PluginContainer = new Snippets();
                        PluginContainer.Text = "Snippets Sidebar Plugin";
                        PluginContainer.Name = "Snippets Sidebar Plugin";
                        PluginContainer.Dock = System.Windows.Forms.DockStyle.Fill;
                        Sidebar.AddSidebarPlugin(PluginContainer);
                    }
                }
            }
            catch { }
        }
        public void Dispose()  {
            if (PluginContainer != null)
            {
                PluginContainer.SaveSnippets();
            }
            try
            {
                Sidebar = SideBarPlugin.Functions.GetSidebarPlugin();
                if (Sidebar != null && PluginContainer != null)
                {
                    if (Sidebar.Controls.ContainsKey(PluginContainer.Name))
                    {
                        Sidebar.RemoveSidebarPlugin(PluginContainer);
                    }
                }
            }
            catch { }
        }
        public void Settings() { }
    }
  
}
